import requests
import json

def inquire_share_status(id,headers):
    url = f"https://perfeye.console.testplus.cn/api/share/task/{id}"
    payload = {}
    response = requests.request("GET", url, headers=headers, data=payload)
    if response.status_code!=200:
      return False
    data=response.json()
    if "data" in data and "IsShared" in data["data"]:
       return data['data']['IsShared']
    return False

def share(id,headers):
    url = f"https://perfeye.console.testplus.cn/api/share/task/{id}"
    payload = json.dumps({
    "TaskID": f"{id}",
    "IsShared": True,
    "IsPrivateShare": False,
    "Password": "",
    "ExpireTime": 0
    })
    response = requests.request("POST", url, headers=headers, data=payload)
    if response.status_code!=200:
      print(f"分享{id}失败！,请求状态码为【{response.status_code}】，请求响应为:【{response.text}】")
      return False
    return True